import 'package:json_annotation/json_annotation.dart';

part 'moto_configg.dart';

@JsonSerializable()
class MotoConfig {
  int? start_off; //启动关闭
  int? cushion; //弹出座垫
  int? find_bike; //一键寻车
  int? lowerpower; //低电量报警
  int? electric_fence; //电子围栏
  int? bluetooth_unlock; //蓝牙靠近解锁
  int? fault_feedback; //故障反馈
  int? security_alert; //安全警报
  int? sit_induction; //乘坐感应
  int? ride_statistics; //骑行统计
  int? track_list; //轨迹列表
  int? bike_location; //车辆位置
  int? imei; //IMEI号
  int? ota_upgrade; //OTA升级
  int? bike_lock; //一键锁车
  int? gps; //车辆GPS
  int? fourg; //4G连接
  int? report_theft; //失窃上报
  int? notice; //消息通知
  int? abnormal; //异常震动
  int? cut_power; //切断电源
  int? charging_monitoring; //充电监测
  int? anti_theft_alarm; //防盗报警
  int? fault_message; //故障消息
  int? key_sharing; //钥匙分享
  MotoConfig();

  factory MotoConfig.fromJson(Map<String, dynamic> json) =>
      _$MotoConfigFromJson(json);
  Map<String, dynamic> toJson() => _$MotoConfigToJson(this);

  static MotoConfig turnConfig(Map data) {
    Map<String, dynamic> datas = {};
    (data['configs'] as Map).forEach((key, value) {
      value.forEach((element) {
        datas[element['key']] = element['status'];
      });
    });

    return MotoConfig.fromJson(datas);
  }
}
